<template>
	<view class="mainContent">
		<view class="header">
			<view class="modular">
				<view class="search">
					<image src="@/static/img/quickly/healthStatus/search@2x.png" mode=""></image>
					<input type="text" placeholder="姓名" v-model="searchVal" @blur="search">
				</view>
			</view>
		</view>
		
		<view class="listMular">
			<uni-swipe-action>
				<view class="box" v-for="(item,index) in list" :key="index">
					<image src="@/static/img/quickly/healthStatus/number@2x.png" class="identifier"></image>
					<uni-swipe-action-item :right-options="options"  @click="bindClick(item)">
						<view class="top">
							<text class="assementNumber">{{item.sn}}</text>
							<text class="dataTime">{{item.assessmentDate}}</text>
						</view>
						<view class="bottom">
							<view class="nameBox">
								<text class="userName">{{item.userName}}</text>
							</view>
							<view class="buttonBox">	
								<view class="qsDetail" @click="detail(item)">汇总详情</view>
								<!-- <view class="applyFor" v-if="item.status == 1" @click="creat(item)">生成评估</view>
								<view class="generating" v-else-if="item.status == 2">生成中</view> -->
								<view class="viewAssessment" @click="read(item)">查看报告</view>
							</view>
						</view>
					</uni-swipe-action-item>
				</view>
			</uni-swipe-action>
			<view class="location">
				<image src="@/static/img/quickly/healthStatus/add@2x.png"  @click="addQuestion"></image>
			</view>
			<view class="noData" v-if="list.length <= 0">
				<image src="@/static/img/quickly/apply/default.png"></image>
				<view>您还没有评估文件~</view>
			</view>
		</view>	
	</view>
</template>

<script>
	export default{
		data() {
			return {
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#EE2437' // 删除按钮背景  红的
					}
				}],
				list:[],
				isNull:false,
				page:1,
				searchVal:''
			}
		},
		onLoad(){
			this.getlist({pageIndex:1,pageSize:10})
		},
		onReachBottom(){
			if(this.isNull){
				return;
			}
			this.page = Number(this.page) + 1
			this.getlist({pageIndex:this.page,pageSize:10})
		},
		methods:{
			search(){
				this.list = []
				this.isNull = false
				this.page = 1
				this.getlist({pageIndex:1,pageSize:10,searchKey:this.searchVal})
			},
			detail(item) {
				uni.navigateTo({url:`/pages/currentSummary/toView?id=${item.id}&userId=${item.userId}`})
			},
			getlist(data){
				const _this = this;
				data.type = 1
				this.$api.getAppAssessSummaryList(data).then((res)=>{
					const data = res.data.result && res.data.result.elements
					if(_this.deleteList == 1) {
						_this.list = []
						_this.list = data
						_this.deleteList = ''
					}else {
						_this.list = _this.list ? _this.list.concat(data) : data
					}
					if(this.list.length >= res.data.result.totalCount){
						this.isNull = true;
					}
				})
			},
			read(item){
				window.location.href = 'http://health.jlm12580.com/web/viewer.html?file='+item.url
			},
			addQuestion() {
				uni.navigateTo({
					url:'/pages/currentSummary/index'
				})
			},
			bindClick(item){
				const _this = this;
				_this.$api.AppAssessSummaryDel(item.id).then((res)=>{
					if(res.data.returnCode == 200){
						_this.page = 1
						_this.isNull = false
						_this.list = []
						_this.getlist({pageIndex:this.page,pageSize:10})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/css/quickly/healthStatus/navigation.scss';
	.listMular {
		margin-top: 102upx !important;
	}
	/deep/ .uni-swipe_box{
		display: block !important;
	}
	/deep/.uni-swipe_button{
		padding: 0 20rpx;
		margin-left: 10rpx;
	}
</style>
